import {
  COLORS_TXT,
} from '../utils/constant';

export type TBinaryTreeNode = BinaryTreeNode | undefined | null;

export class BinaryTreeNode {
  public key: any;
  public left: TBinaryTreeNode;
  public right: TBinaryTreeNode;

  public constructor(key: any) {
    this.key = key;
    this.left = null;
    this.right = null;
  }
}

export type TRedBlackTreeNode = RedBlackTreeNode | undefined | null;
export  class RedBlackTreeNode extends BinaryTreeNode {
  public color: COLORS_TXT;
  public parent: TRedBlackTreeNode;
  public left: TRedBlackTreeNode;
  public right: TRedBlackTreeNode;

  public constructor(key: any, color: COLORS_TXT) {
    super(key);
    this.color = color;
    this.parent = null;
  }

  public isRed() {
    return this.color === COLORS_TXT.RED;
  } 
}
